<?xml version="1.0" encoding="gb2312"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:param name="languageCode" />
  <!--
	if a label does not exist, which language to use as the default
-->
  <xsl:variable name="defaultLanguageCode">
    <xsl:text>1033</xsl:text>
  </xsl:variable>
  <xsl:template match="/preview">
    <table width="100%" height="100%" cellspacing="0" cellpadding="0">
      <!-- 
				Generic Grid header, always constant
			-->
      <tr height="22">
        <td>
          <table id="gridBar" cellpadding="0" cellspacing="0" class="gridBar">
            <tr id="trHeader" pagesize="">
              <td width="20">
                <input type="checkbox" onclick="return false;">
                </input>
              </td>
              <td width="20" style="cursor:default;">
              </td>
              <td width="20" style="cursor:default;">
              </td>
              <td class="gridSpacer">
                <img src="../../_grid/imgs/bar_line.gif">
                </img>
              </td>
              <td width="10">
              </td>
              <td nowrap="">Column<img src="../../_grid/imgs/bar_up.gif" style="visibility:visible;"></img></td>
              <td class="gridSpacer">
                <img src="../../_grid/imgs/bar_line.gif">
                </img>
              </td>
              <td width="14">
                <img src="../../_grid/imgs/grid_Refresh.gif">
                </img>
              </td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td>
          <table width="100%" height="100%" style="background-color:#ffffff;" cellpadding="0" cellspacing="0">
            <tr>
              <td>
                <!-- 
									Create a generic grid item to display what the preview will look like.
								-->
                <div style="text-align:center;font-size:11px;color:#999999;width:100%;height:100%;overflow-y:scroll;">
                  <table id="tempGridItem" cellpadding="0" cellspacing="0" class="gridItem">
                    <td width="20">
                      <input type="checkbox" onclick="return false;">
                      </input>
                    </td>
                    <td width="20">
                      <img src="../../_grid/imgs/grid_d.gif">
                      </img>
                    </td>
                    <td width="20">
                      <img src="../../_imgs/ico_16_1.gif">
                      </img>
                    </td>
                    <td width="10">
                    </td>
                    <td>Grid Item</td>
                  </table>
                  <!-- 
										Preview 
									-->
                  <table cellspacing="0" cellpadding="0" style="table-layout: fixed;">
                    <col width="20" />
                    <col />
                    <tr>
                      <td>
                      </td>
                      <td>
                        <table id="rowsContent" cellspacing="4" cellpadding="4" class="section">
                          <col />
                          <col />
                          <xsl:for-each select="rows/row">
                            <tr id="previewContect" valign="top">
                              <xsl:choose>
                                <!-- cell spans both columns -->
                                <xsl:when test="not(cell[2])">
                                  <xsl:apply-templates select="cell[1]">
                                    <xsl:with-param name="colspan">true</xsl:with-param>
                                  </xsl:apply-templates>
                                </xsl:when>
                                <xsl:otherwise>
                                  <xsl:choose>
                                    <xsl:when test="cell[1]/@name">
                                      <xsl:apply-templates select="cell[1]" />
                                    </xsl:when>
                                    <xsl:otherwise>
                                      <td>
                                      </td>
                                    </xsl:otherwise>
                                  </xsl:choose>
                                  <xsl:choose>
                                    <xsl:when test="cell[2]/@name">
                                      <xsl:apply-templates select="cell[2]" />
                                    </xsl:when>
                                    <xsl:otherwise>
                                      <td>
                                      </td>
                                    </xsl:otherwise>
                                  </xsl:choose>
                                </xsl:otherwise>
                              </xsl:choose>
                            </tr>
                          </xsl:for-each>
                        </table>
                      </td>
                    </tr>
                  </table>
                </div>
              </td>
            </tr>
            <tr>
              <td style="height:21px; background-color: #E9E7D7;background-image: url(/_grid/imgs/bar_bk.gif);">
                <br />
              </td>
            </tr>
          </table>
        </td>
      </tr>
    </table>
  </xsl:template>
  <xsl:template match="/preview/rows/row/cell">
    <xsl:param name="colspan" />
    <xsl:variable name="fieldName" select="@name" />
    <td class="cell" onclick="SetActiveObject();" ondblclick="ViewPropertiesNow();">
      <xsl:if test="$colspan">
        <xsl:attribute name="colspan">2</xsl:attribute>
      </xsl:if>
      <xsl:attribute name="name">
        <xsl:value-of select="@name" />
      </xsl:attribute>
      <table cellspacing="0" cellpadding="0">
        <col />
        <tr height="18">
          <td nowrap="" class="label">
            <xsl:choose>
              <xsl:when test="/preview/properties/fields/field[@name = $fieldName]/displaynames/displayname[@languagecode = $languageCode]">
                <xsl:value-of select="/preview/properties/fields/field[@name = $fieldName]/displaynames/displayname[@languagecode = $languageCode]/@description" /> :
							</xsl:when>
              <xsl:otherwise>
                <xsl:value-of select="/preview/properties/fields/field[@name = $fieldName]/displaynames/displayname[@languagecode = $defaultLanguageCode]/@description" /> :
							</xsl:otherwise>
            </xsl:choose>
          </td>
        </tr>
      </table>
    </td>
  </xsl:template>
</xsl:stylesheet>